<?php

namespace App\Http\Requests\Admin\Panx\Product;

use App\Http\Requests\ApiRequest;

/**
 * @property array spec_values
 */
class ProductSpecUpdateRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
    
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'product_mod_id'    => 'required|int|min:1',
            'name'                => ['required', 'string', 'min:1'],
            'spec_values'         => 'required|array',
            'spec_values.*'       => 'required|array',
            'spec_values.*.id'    => 'required|int|min:0',
            'spec_values.*.value' => 'required|string|min:1',
        ];
    }
    
    /**
     * @return array
     */
//    public function messages()
//    {
//        return [
//            'product_mod_id.*'    => '商品模型的id必须是数值',
//            'name.*'                => '规格名称必须是字符串',
//            'spec_values.*'         => '规格必须是数组',
//            'spec_values.*.*'       => '规格值必须是数组',
//            'spec_values.*.id.*'    => '规格值ID必须是整数',
//            'spec_values.*.value.*' => '规格值的内容不能为空',
//        ];
//    }
}
